<template>
  <div class="one">
    <h3>当日订单展示</h3>
    <template>
      <el-table :data="postList" :row-style="{ height: '170px' }">
        <el-table-column width="50px" class="column" prop="flowid" label="序号">
        </el-table-column>
        <el-table-column class="column" prop="wdr" label="wdr号">
        </el-table-column>
        <el-table-column
          class="column"
          width="63px"
          prop="orderNo"
          label="订单号"
        >
        </el-table-column>
        <el-table-column class="column" prop="orderNo" label="订单操作">
          <template slot-scope="scope">
            <div class="dingDancaozuo">
              <el-button
                class="star"
                @click="shangYi(scope.row.id)"
                type="text"
                size="medium"
                >上移</el-button
              >
              <el-button
                class="star"
                @click="downYi(scope.row.id)"
                type="text"
                size="medium"
                >下移</el-button
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column class="column" label="生产管理">
          <template slot-scope="scope1">
            <div class="shengChanguanli">
              <el-button
                class="star"
                @click="starOrder(scope1.row.id)"
                type="text"
                size="medium"
                >开始订单</el-button
              >
              <el-button
                class="star"
                @click="suspendOrder(scope1.row.id)"
                type="text"
                size="medium"
                >暂停订单</el-button
              >
              <el-button
                class="star"
                @click="endOrder(scope1.row.id)"
                type="text"
                size="medium"
                >结束订单</el-button
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </div>
</template>

<script>
import {
  ordercart1,
  setprod,
  finish,
  stop,
  setprodList,
  finishList,
  stopList,
} from "@/api/system/from";
import { listUp1, listDown1 } from "@/api/system/manage";
import iphoneXq from "@/views/system/iphoneXq/index";
export default {
  name: "dingdan",
  data() {
    return {
      loading: false,
      finished: false,
      postList: [],
      // 总条数
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 11,
        flowid: null,
        wdr: null,
        orderNo: null,
        partNo: null,
        orderDescribe: null,
        orderNum: null,
        orderState: null,
        progress: null,
        productTime: null,
        endTime: null,
        id: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询岗位列表 */
    getList() {
      ordercart1(this.queryParams).then((response) => {
        console.log("yyds", response.list);
        this.postList = response.list;
        console.log(this.postList);
      });
    },
    handleDelete(row) {
      const id = row.id || this.id;
      this.$modal
        .confirm("是否确认生产")
        .then(function () {
          return setprod(id);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("确定生产成功");
        })
        .catch(() => {});
    },
    handleUpdate(row) {
      const id = row.id || this.id;
      this.$modal
        .confirm("是否结束生产")
        .then(function () {
          return finish(id);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("生产完成");
        })
        .catch(() => {});
    },
    handledown(row) {
      const id = row.id || this.id;
      this.$modal
        .confirm("是否暂停生产")
        .then(function () {
          return stop(id);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("暂停生产完成");
        })
        .catch(() => {});
    },
    shangYi(id) {
      listUp1(id).then((res) => {
        this.getList();
      });
    },
    downYi(id) {
      listDown1(id).then((res) => {
        this.getList();
      });
    },
    starOrder(id) {
      console.log(id);
      setprodList(id).then((res) => {
        console.log("yyds1", res);
        alert("订单已开始");
        this.getList();
      });
    },
    suspendOrder(id) {
      stopList(id).then((res) => {
        console.log("yyds2", res);
        alert("订单已暂停");
        this.getList();
      });
    },
    endOrder(id) {
      console.log(id);
      finishList(id).then((res) => {
        console.log("yyds3", res);
        alert("订单已结束");
        this.getList();
      });
    },
  },
};
</script>

<style>
h3 {
  text-align: center;
  font-size: 35px;
  color: #6280c6;
}
#down {
  float: left;
  margin-left: 20px;
}
.dingDancaozuo {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-content: center;
}
.dingDancaozuo .star {
  flex-grow: 2;
  width: 60px;
  height: 30px;
  text-align: center;
  margin-left: 4px;
}
.shengChanguanli {
  display: flex;
  flex-direction: column;
}
.shengChanguanli .star {
  width: 60px;
  height: 30px;
  text-align: center;
  margin-left: 3px;
  flex-grow: 1;
}
.cell {
  text-align: center;
}
</style>
